package com.damage.common.object;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BaseResp {

    private int code;
    private Object data;
    private String errorMsg;

    public static BaseResp ok() {
        return BaseResp.builder()
                .code(1)
                .build();
    }

    public static BaseResp ok(Integer successCode) {
        return BaseResp.builder()
                .code(successCode)
                .build();
    }

    public static BaseResp ok(Object obj) {
        return BaseResp.builder()
                .code(1)
                .data(obj)
                .build();
    }


    public static BaseResp ok(Integer successCode, Object obj) {
        return BaseResp.builder()
                .code(successCode)
                .data(obj)
                .build();
    }

    public static BaseResp error() {
        return BaseResp.builder()
                .code(0)
                .build();
    }

    public static BaseResp error(Integer errorCode) {
        return BaseResp.builder()
                .code(errorCode)
                .build();
    }

    public static BaseResp error(String errorMsg) {
        return BaseResp.builder()
                .code(0)
                .errorMsg(errorMsg)
                .build();
    }

    public static BaseResp error(Integer code, String errorMsg) {
        return BaseResp.builder()
                .code(code)
                .errorMsg(errorMsg)
                .build();
    }
}
